package sktit.practice.jpaint.util;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

import sktit.practice.jpaint.shape.Shape;

public class ShapeUtils {
	
	public static boolean isInside(Point point, Shape shape)
	{
		return false;
	}
	
	public static double getArea(Shape shape)
	{
		return shape.getArea();
	}
	
	public static double getPerimeter(Shape shape)
	{
		return shape.getPerimeter();
	}
	
	public static Point[] getBorder()
	{
		Point[] border = new Point[1];
		return border;
	}
	
	public static double getLine(Point p1, Point p2)
	{
		return Math.sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
	}
	
	/**
	 * Create a graphical rectangle from a border
	 * @param vertex
	 * @return
	 */
	public static Rectangle generate(Point[] vertex)
	{
		return ShapeUtils.generate(vertex[0], vertex[2]);
	}
	
	/**
	 * Create a graphical rectangle from two opposite point
	 * @param p1
	 * @param p2
	 * @return
	 */
	public static Rectangle generate(Point p1, Point p2)
	{
		return new Rectangle(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.abs(p1.x - p2.x), Math.abs(p1.y - p2.y));
	}
	
	
}
